import store from '../vuex/store'

/**
 * 检测角色是否有某个操作权限
 * @param APPID
 * @param 
 * @param 
 * @returns {boolean}
 */

export function havePower(APPID) {
    const powerData = store.state.login.authority.data;//[obj,obj..]
    const havePower = powerData.some((item,index)=>{
        if (item.APPID == APPID) {
            return true
        }
    });
    return havePower;
}

/**
 * 检测角色当前的权限列表
 * @param APPID
 * @param 
 * @param 
 * @returns {boolean}
 */

export function powerList() {
    const powerData = store.state.login.authority.data;//[obj,obj..]
    const powerLists = powerData.map((item,index)=>{
        return item.MC
    });
    // console.log(powerLists)
    return powerLists;
}

export default {
    havePower,
    powerList
}